package com.mrjy.wechat.util;

import javax.servlet.ServletContext;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

/** 
* @ClassName: ServletContextUtil  
* @author csshui 
* @date 2017年04月25日 下午4:00  
* @Description: 
*       全局缓存servletcontext 
 */
public class ServletContextUtil {
	 private static ServletContext serveltContext = null;  
     
    private ServletContextUtil(){};  
      
    public synchronized static ServletContext get() {  
          
        if(null == serveltContext) {  
            WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();    
            serveltContext = webApplicationContext.getServletContext();   
        }   
        return serveltContext;  
    }
}
